package com.gec.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gec.model.entity.SysParking;
import com.gec.model.entity.SysRepair;
import com.gec.model.vo.SysRepairVo;
import com.gec.system.mapper.SysRepairMapper;
import com.gec.system.service.SysRepairService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 维修表  用于记录用户报修信息 服务实现类
 * </p>
 *
 * @author lmd
 * @since 2023-12-08
 */
@Service
public class SysRepairServiceImpl extends ServiceImpl<SysRepairMapper, SysRepair> implements SysRepairService {

    @Autowired
    private SysRepairMapper sysRepairMapper;

    @Override
    public IPage<SysRepair> selectPage(IPage<SysRepair> iPage, SysRepairVo sysRepairVo) {
        return this.sysRepairMapper.selectPage(iPage, sysRepairVo);
    }

    @Override
    public void updateRepairStatus(Long id, Integer status) {
        //1.查询出当前设备
        SysRepair sysRepair = this.baseMapper.selectById(id);
        //2.设置状态
        sysRepair.setStatus(status);
        //3.更新
        this.baseMapper.updateById(sysRepair);
    }

    @Override
    public List<SysRepair> findAllRepairByStatus(Integer status) {
        QueryWrapper<SysRepair> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("status", status);
        List<SysRepair> sysRepairs = this.sysRepairMapper.selectList(queryWrapper);
        return sysRepairs;
    }
}
